package com.zjsy.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zjsy.po.Defaults;
import com.zjsy.po.FriendLink;
import com.zjsy.po.Magazine;
import com.zjsy.po.MainNewsModule;
import com.zjsy.po.Message;
import com.zjsy.service.DefaultService;
import com.zjsy.service.FriendLinkService;

@Controller
public class DefaultController {
	
	@Autowired
	private DefaultService defaultservice;
	
	@RequestMapping("/default-list")
	public String defaultList(HttpServletRequest req,HttpServletResponse resp) {
		List<Defaults> list=defaultservice.findDefault();
		req.setAttribute("list", list);
		return "default-list";
	}
	
	@RequestMapping("/default-edit")
	public String defaultEdit(HttpServletRequest req,HttpServletResponse resp) {
		String id=req.getParameter("id");
		Defaults defaults=defaultservice.findDefaultById(id);
		req.setAttribute("defaults", defaults);
		return "default-edit";
	}
	
	
	
	@RequestMapping("/default-update")
	@ResponseBody
	public Message defaultUpdate(HttpServletRequest req,HttpServletResponse resp,@RequestBody Defaults defaults) {
		defaultservice.updateDefault(defaults);
		
		return new Message("更新成功");
	}
	

}
